<?php
$url = 'code.php';
if($_GET['type']=='pycharm'){
    $url = 'code.php?type=pycharm';
}else if($_GET['type']=='idea'){
    $url = 'code.php?type=idea';
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Natpacket's tools</title>
    <link rel="shortcut icon" href="https://assets.shimonote.com/from_qbox/sheet_favicon.ico">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="CryptoJS.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
    </script>
</head>
<body>
<div id="app">
    <el-container>
<!--        <el-header>-->
<!--            -->
<!--        </el-header>-->
        <el-main>
            <el-table
                    :data="urls"
                    stripe
                    style="width: 300px">
                <el-table-column
                        fixed
                        label="链接"
                        width="100">
                    <template slot-scope="scope">
                        <a>{{ scope.row.name }}</a>
                    </template>
                </el-table-column>
                <el-table-column
                        fixed="right"
                        label="操作"
                        width="120">
                    <template slot-scope="scope">
                        <el-button
                                id="copyMe"
                                @click="openUrl(scope.$index, urls)"
                                type="text"
                                size="small">
                            go
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer></el-footer>
    </el-container>
</div>
</body>
<!--@click="copy(scope.$index, codes)"-->
<!-- 先引入 Vue -->
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.6/dist/clipboard.min.js"></script>
<script>
    var app = new Vue({
        el: "#app",
        data: {
            urls: [
                {name: 'InteliJ通用激活码', url: 'jihuoma.php'},
                {name: 'V2ray订阅链接', url: 'ishadowV2ray.php'},
                {name: 'wangzi.uk签到', url: 'checkin.php'},
                {name: 'iccid', url: 'iccid.html'}
            ],
        },
        methods: {
            openUrl(index, urls) {
                window.open(urls[index]['url'], '_blank')
            },
            copy(index, data) {
                var clipboard = new ClipboardJS("#copyMe", {
                    text: function () {
                        //寻找被激活的那个div pre元素,同时获取它下面的内容
                        //alert(data[index]['value']);
                        return data[index]['value'];
                    }
                });

                clipboard.on('success', function (e) {
                    alert("已复制到粘贴板！");
                    console.log(e);
                });

                clipboard.on('error', function (e) {
                    console.log(e);
                });
            }
        },
    });

</script>
</html>